package com.diamond.webservice.entity;

import lombok.Data;

import java.io.Serializable;

@Data
public class Page<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private int pageNo = 1;
    private int pageSize = 10;
    private int pageBegin = 0;
    private int pageEnd = 0;
    private T param;

    public Page(int pageNo, int pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.pageBegin = (pageNo - 1) < 0 ? 0 : (pageNo - 1) * pageSize;
        this.pageEnd = pageNo < 0 ? 1 : pageNo * pageSize;
    }

    public int getPageBegin() {
        return (pageNo - 1) < 0 ? 0 : (pageNo - 1) * pageSize;
    }

    public void setPageBegin(int pageBegin) {
        this.pageBegin = pageBegin;
    }

    public int getPageEnd() {
        return pageNo < 0 ? 1 : pageNo * pageSize;
    }

    public void setPageEnd(int pageEnd) {
        this.pageEnd = pageEnd;
    }
}
